package org.syntaxlisp.core.element;

import lombok.Getter;

/**
 * @author HuangYijun
 * @data 2023-01-29 11:32
 **/
public class CharacterElement extends SyntaxLispElement {

    @Getter
    private final int codepoint;

    @Getter
    private final char charVal;

    public CharacterElement(String val, int codepoint) {
        super(SyntaxLispElementType.CHARACTER, val);
        this.codepoint = codepoint;
        charVal = (char) codepoint;
    }

    @Override
    public boolean equalsTo(SyntaxLispElement o) {
        return codepoint == ((CharacterElement) o).getCodepoint();
    }

    @Override
    public int hashCode () {
        return codepoint;
    }

    @Override
    public SyntaxLispElement copy() {
        return (new CharacterElement(getVal(), codepoint)).copyMatchPropertiesAndReturn(this);
    }
}
